﻿#region

using System;
using System.Collections.Generic;
using System.Web.UI;
using BusinessLogicLayer;
using BusinessObjects;

#endregion

namespace FastTrackCabService.CustomerPanel
{
    public partial class BookingFullView : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            int bookingId;
            if (int.TryParse(Request.QueryString["bookingId"], out bookingId))
            {
                if (IsPostBack) return;
                var bookingType = BookingBLL.GetBookingType(bookingId);
                switch (bookingType)
                {
                    case null:
                        Response.Redirect("Default.aspx");
                        break;
                    case "PICK & DROP":
                    {
                        var booking = PickAndDropBookingBLL.GetBooking(bookingId);
                        dvPickAndDrop.Visible = true;
                        dvPickAndDrop.DataSource = new List<PickAndDropBooking> {booking};
                        dvPickAndDrop.DataBind();
                    }
                        break;
                    default:
                    {
                        var booking = PickBookingBLL.GetBooking(bookingId);
                        dvPick.Visible = true;
                        dvPick.DataSource = new List<PickBooking> {booking};
                        dvPick.DataBind();
                    }
                        break;
                }
            }
            else
            {
                Response.Redirect("Default.aspx");
            }
        }
    }
}